package cn.readjava.dao;

import cn.readjava.bean.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Set;

public interface RoleDao extends JpaRepository<Role, Long> {

    @Query(value = "SELECT r.role_name FROM user u LEFT JOIN user_role ur ON u.user_id = ur.u_id LEFT JOIN role r ON ur.r_id = r.role_id WHERE user_id = ?1", nativeQuery = true)
    Set<String> findAllRole(long userId);
}
